package com.alex.ioc.factory;

import java.util.HashMap;
import java.util.Map;

/**
 * 静态工厂方法
 */
public class StaticCarFactory {

    public static Map<String, Car> cars=new HashMap<>();

    static {
        System.out.println("init StaticCarFactory ...");
        cars.put("audi", new Car("bmw", 300000.0));
        cars.put("bmw", new Car("bmw", 360000.0));
        cars.put("benz", new Car("benz", 450000.0));
    }

    public static Car getCar(String name) {
        return cars.get(name);
    }
}
